public class listcontacts {

    List<Contact> list_contacts;
    public listcontacts(ApexPages.StandardSetController controller) {
        list_contacts=(List<Contact>)controller.getSelected();
        System.debug('total size of the selected contacts-->'+list_contacts.size());
        System.debug('total size of the selected contacts-->'+list_contacts);
        //delete list_contacts;
    }
    public pageReference deleteContactRec()
    {
    String Accounidval=list_contacts[0].AccountId;
        delete list_contacts;
     return new PageReference('/'+Accounidval);
     //return null;
    }

}